//
//  HPReviewStateViewController.m
//  HPZZTong
//
//  Created by Handpay on 14-3-30.
//  Copyright (c) 2014年 Handpay. All rights reserved.
//

#import "HPReviewStateViewController.h"
#import "DefineUtil.h"

@interface HPReviewStateViewController ()
@property(nonatomic, retain)UILabel* desLabel;
@end

@implementation HPReviewStateViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        
    }
    return self;
}

- (void)viewDidLoad
{
    self.title = @"资质信息";
    [super viewDidLoad];
    
    UILabel* tempLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, 70, 270, 1000)];
    tempLabel.textColor = kNormalFontColor;
    tempLabel.font = kNormalFont;
    tempLabel.text = ZZT_CLIENG.accountInfo.statusDescpriction;
    tempLabel.numberOfLines = 0;
    [tempLabel sizeToFit];
    self.desLabel = tempLabel;
    [tempLabel release];
    
    self.licenseTableView.dataSource = self;
    self.licenseTableView.delegate = self;
    
    CGRect licenseFrame = self.licenseTableView.frame;
    licenseFrame.size.height = self.desLabel.frame.origin.y + self.desLabel.frame.size.height + 19;
    self.licenseTableView.frame = licenseFrame;
    if (licenseFrame.size.height < (ScreenHeight - IOS7_VIEW_FRAME_Y)) {
        self.licenseTableView.scrollEnabled = NO;
    }
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 1;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return self.desLabel.frame.origin.y + self.desLabel.frame.size.height + 20;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewCell* cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil];
    
    UILabel* questionLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, 15, 280, 44)];
    questionLabel.font = [UIFont systemFontOfSize:18];
    if (ZZT_CLIENG.accountInfo.accountStatus == AccountStatusFailed) {
        questionLabel.textColor = kRedFontColor;
        questionLabel.text = @"资质审核未通过......";
        [cell setSelectionStyle:UITableViewCellSelectionStyleGray];
        [cell setAccessoryType:UITableViewCellAccessoryDisclosureIndicator];
    }else if (ZZT_CLIENG.accountInfo.accountStatus == AccountStatusReview){
        questionLabel.textColor = kLicFontColor;
        questionLabel.text = @"资质审核中......";
        [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
        cell.userInteractionEnabled = NO;
    }
    [cell addSubview:questionLabel];
    [questionLabel release];
    
    [self.desLabel removeFromSuperview];
    [cell addSubview:self.desLabel];
    
    return [cell autorelease];
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    [ZZT_CLIENG submitQuality];
}

- (void)dealloc {
    self.desLabel = nil;
    
    [_licenseTableView release];
    [super dealloc];
}
- (void)viewDidUnload {
    [self setLicenseTableView:nil];
    [super viewDidUnload];
}
@end
